<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//全局化变量
$CI =& get_instance();
$CI->load->library('session');
//前台公用页面load_w_view('index');——www
function load_view($moban="index",$data=""){
	//这一句就是用来代替This用的$flag用来判断登录状态
	global $CI;
	$CI->load->view('www/header',$data);
	$CI->load->view('www/menu');
	$CI->load->view('www/left',$data);
	$CI->load->view('www/'.$moban,$data);
	$CI->load->view('www/footer');
}

//会员中心页面部分
function load_member_view($left="member_left",$mid="order_my",$data=""){
	//这一句就是用来代替This用的
	global $CI;
	$CI->load->view('www/header',$data);
	$CI->load->view('www/menu');
	$CI->load->view('www/'.$left,$data);
	$CI->load->view('www/'.$mid,$data);
	$CI->load->view('www/footer');
}

//后台页面部分
//function load_admin_view(){}


//自定义函数redirecter
function redirecter($msg,$url,$delay=3){
	global $CI;
	$params = array('msg'=>"$msg",'url'=>site_url("$url"),'delay'=>$delay);
	$CI->load->view('www/redirect',$params);
}

//afei自定义的CI分页函数
function pagebar($base_url,$total,$per_page){
	global $CI;
	$config['base_url'] = $base_url;//http://localhost/ci/index.php/netbar/area/$id
	$config['total_rows'] = $total;
	$config['per_page'] = $per_page;
	$config['uri_segment'] = 4;//http://localhost/ci/index.php/netbar/area/1/14[也就是14在哪个位置]
	$config['num_links'] = 3;//改小一点试试就明白了
	$config['full_tag_open'] = '<div class="pagebar">';
	$config['full_tag_close'] = '</div>';
	$config['cur_tag_open'] = '<span class="current">';
	$config['cur_tag_close'] = '</span>';
	$config['first_link'] = '&#171;';
	$config['last_link'] = '&#187;';
	$config['next_link'] = '&gt;';
	$config['prev_link'] = '&lt;';
	//初始化分页
	$CI->pagination->initialize($config);
	return $page_html = $CI->pagination->create_links();
}


/*
 * KNDB Session相关简化函数
 **
 * @access: public
 * @author: afei
 * @param: 无
 * @return:无

*/
	//设置Session
	function set_session($session_name,$session_val=""){
		global $CI;
		if($session_val!=""){//单个赋值的形式
			return $CI->session->set_userdata($session_name,$session_val);
		}else{//数组的形式
			return $CI->session->set_userdata($session_name);
		}
	}
	//获取Session
	function get_session($session_name){
		global $CI;
		return $CI->session->userdata($session_name);
	}
	//销毁Session
	function unset_session($session_name){
		global $CI;
		return $CI->session->unset_userdata($session_name);
	}


?>